import { Injectable, NotAcceptableException } from '@nestjs/common'
import { Prisma } from '@prisma/client'
import { PrismaService } from 'src/prisma/prisma.service'

@Injectable()
export class ShopService {
  constructor(private readonly prismaService: PrismaService) {}

  async createAndUpdateShop(data: Prisma.ShopCreateInput) {
    const hasShop = await this.prismaService.shop.findMany()
    if (hasShop.length) await this.prismaService.shop.deleteMany()
    const shop = await this.prismaService.shop.create({
      data
    })
    return shop
  }

  async getShop() {
    const shop = await this.prismaService.shop.findFirst()
    return shop
  }
}
